//
//  ServerRequestTool.h
//  NewJiaZheng
//
//  Created by lianjie on 2017/12/1.
//  Copyright © 2017年 kangbinbin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "BaseRequestManager.h"
#import "NetworkError.h"


typedef void(^HttpUploadSuccessBlock)(id Json);
typedef void(^HttpUploadFailureBlock)();

@interface ServerRequestTool : NSObject

///GET请求方式：1、请求类型为JSON类型；2、返回类型为JSON类型；3、编码方式为：@“application/x-www-form-urlencoded; charset=utf-8”
+ (void) GET:(NSString *)URLString parameters:(id)parameters success:(void (^)(id))success control:(UIViewController *)ctrl;



///POST请求方式：请求类型为JSON类型；返回类型为JSON类型；编码方式为：@“application/x-www-form-urlencoded; charset=utf-8”
+(void)POST:(NSString *)URLString parameters:(id)parameters success:(void (^)(id))success control:(UIViewController *)ctrl;

///json格式
+(void)POST:(NSString *)URLString parametersJSON:(id)parameters success:(void (^)(id))success control:(UIViewController *)ctrl;

///返回错误操作
+(void)POST:(NSString *)URLString parameters:(id)parameters success:(void (^)(id))success failureCode:(void (^)(id))failureCode control:(UIViewController *)ctrl;
/**
 *  上传图片(单张)
 *
 *  @param path    路径
 *  @param image   图片
 *  @param params  参数
 *  @param success 成功回调
 *  @param failure 失败回调
 */
+ (void)uploadImageWithPath:(NSString *)path image:(UIImage *)image params:(NSDictionary *)params success:(HttpUploadSuccessBlock)success failure:(HttpUploadFailureBlock)failure control:(UIViewController *)ctrl;

/**
 *  上传图片(多张)
 *
 *  @param path    路径
 *  @param photos  图片数组
 *  @param params  参数
 *  @param success 成功回调
 *  @param failure 失败回调
 */
+ (void)uploadImageWithPath:(NSString *)path photos:(NSArray *)photos params:(NSDictionary *)params success:(HttpUploadSuccessBlock)success failure:(HttpUploadFailureBlock)failure control:(UIViewController *)ctrl;

@end
